<?php
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
include 'PHPMailer/src/Exception.php';
include 'PHPMailer/src/SMTP.php';
include 'PHPMailer/src/PHPMailer.php';
$mail = new PHPMailer(true);// Passing `true` enables exceptions

//Server settings
$mail->SMTPDebug = 2;                                 // Enable verbose debug output
$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also accepted
// $mail->Host = '108.177.97.108';  // Specify main and backup SMTP servers
$mail->Host = 'smtp.googlemail.com';  // Specify main and backup SMTP servers
// $mail->Host = 'smtp.126.com';  // Specify main and backup SMTP servers
$mail->SMTPOptions = array(
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true,
    )
);
// $mail->Port = 587;                                    // TCP port to connect to
$mail->Port = 465;                                    // TCP port to connect to
$mail->Username = 'ha_tpscfddc@xapp.tw';                 // SMTP username
// $mail->Username = 'ljwnet122@126.com';                 // SMTP username
$mail->Password = '%CEy7UaY';                           // SMTP password

//Recipients
// $mail->setFrom('ha_tpscfddc@mail.taipei.gov.tw', 'Mailer');
$mail->setFrom('ljwnet122@126.com', 'ljwnet122');
$mail->addAddress('916617109@qq.com', 'Way User');     //添加收件人
//Content
$mail->isHTML(true);                                  // Set email format to HTML
$mail->CharSet  ="utf-8";
$mail->Subject = 'aaHere is the xxx主题'.__FILE__;
$mail->Body    = 'aaThis is <h2>内容 ->>>>现在的事件是'.date("Y-m-d H:i:s").'</h2>';
$mail->AltBody = 'aaThis is the AltBody';

try {
    $mail->send();
    echo 'Message has been sent';
} catch (Exception $e) {
	echo '<pre>';
	// var_export($mail);
	echo '</pre>';
    echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}